
# initialize
library(RWeka)
source("./config")
source("./fun.R")

# kNN classifier
kNN.cl <- IBk(Topic ~., data = r.train, control = Weka_control(K = k_value))
kNN.pr <- predict(kNN.cl, r.test[,-n])

# Error rate
kNN.er <- sum(as.character(r.test[,n]) == as.character(kNN.pr))/length(r.test[,n])

# other quality measures
kNN.sen <- sensitivity_M(as.character(r.test[,n]), as.character(kNN.pr))
kNN.spe <- specificity_M(as.character(r.test[,n]), as.character(kNN.pr))
kNN.fm <- Fmeasure(as.character(r.test[,n]), as.character(kNN.pr))
kNN.ta <- TA(as.character(r.test[,n]), as.character(kNN.pr))

